// pages/index/infor/location/modifylocation/modifylocation.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
   locationid:{},
   username:"",
   location:"",
   replenish:"",
   phone:"",

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  

  },

  phone (e){
    this.setData({
      phone:e.detail
    })
  },
  replenish (e){
    this.setData({
      replenish:e.detail
    })
  },
  username (e){
    this.setData({
      username:e.detail
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  map: function () {
    var that = this
    wx.chooseLocation({
      success: function (res) {
        // success
        if (res.name == '') {
          that.setData({
            location: '选择位置',
          })
        } else {
          that.setData({
            location: res.name,
          })
        }
      },
    })
  },
  
  insertAddress(){
    let that = this
    console.log(that.data)
    wx.request({
      url: 'http://192.168.19.114:8080/blm_war_exploded/insertAddress',
      method:"POST",
      // header:{
      //   // "cookie":wx.getStorageSync('sessionid'),
      //   // "Authorization":wx.getStorageSync('session')
      // }, 
     data:{
       address:that.data.location,
       name:that.data.username,
       detailedAddress: that.data.replenish,
       mobile:that.data.phone,
       user:{
         id:20,
       }
     },
     success (res) {
       that.setData({
      
       })
      console.log(res)
  
    }
    })
  },


  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})